﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CNDreams.Web.Base;
using CNDreams.Web.Models;
using CNDreams.Entity;
using CNDreams.Enum;
using Project.Common;
using Project.Web.Base;
using Project.Web.Base.Utility;
using CNDreams.ServiceInterface;

namespace CNDreams.Web.Controllers
{
	public class TreePageController : BaseController
	{
		private IServiceUTOrgDepartment bizUTOrgDepartment;
		private IServiceSysRole bizSysRole;
		private IServiceSysCodeType bizSysCodeType;
		private IServiceSysMenu bizSysMenu;
		private IServiceSysUserType bizSysUserType;
		private IServiceUTOrganization bizUTOrganization;

		public ActionResult Index()
		{
			return View();
		}

		public ActionResult SysUserTypeManageIndex()
		{
			var list = bizSysUserType.List(ReflectionTools.SerializeExpression<SysUserType>(x => x.Name), EnumOrder.ASC);
			SelectList sysUserTypeCollenction = SelectListHelper.ComposeSelectListFromCollect(list, x => x.ID, x => x.Name);
			return View(sysUserTypeCollenction);
		}

		public ActionResult SysMenuManageIndex()
		{
			ViewBag.FrameUrl = "/ModuleSys/SysMenuManage/Index";
			var treeDataSources = bizSysMenu.List(ReflectionTools.SerializeExpression<SysMenu>(x => x.OrderIndex), EnumOrder.ASC);
			return View(treeDataSources);
		}

		public ActionResult SysOrgDepartmentManageIndex()
		{
			ViewBag.FrameUrl = "/ModuleSys/SysOrgDepartmentManage/Index";
			ModelTreePageSysOrganizationManageIndex modelObj = new ModelTreePageSysOrganizationManageIndex();
			modelObj.RetriveData();
			return View(modelObj);
		}

		public ActionResult SysUserManageIndex(ModelTreePageUTOrgDepartmentManageIndex model)
		{
			ViewBag.FrameUrl = "/ModuleSys/SysUserManage/Index";
			model.RetriveData();
			return View(model);
		}

		public ActionResult SysRoleManageIndex()
		{
			var list = bizSysRole.List(ReflectionTools.SerializeExpression<SysRole>(x => x.CreateTime), EnumOrder.ASC);
			SelectList sysRoleCollection = SelectListHelper.ComposeSelectListFromCollect(list, x => x.ID, x => x.RoleName);
			return View(sysRoleCollection);
		}

		public ActionResult SysUserRightIndex(ModelTreePageSysUserRightIndex model)
		{
			model.RetriveData();
			return View(model);
		}

		public ActionResult ParameterSettingsIndex()
		{
			IList<SysCodeType> sysCodeTypeCollection = bizSysCodeType.ListBy(ReflectionTools.SerializeExpression<SysCodeType>(x => x.Class == (int)EnumCodeTypeClass.可维护), ReflectionTools.SerializeExpression<SysCodeType>(x => x.SortOrder), EnumOrder.ASC);
			return View(sysCodeTypeCollection);
		}
	}
}
